package com.hyt.it.ogt.kq.service.gov.roomdata;

import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;

/**
 * @author 刘恒活
 * @since 2021/9/26 10:48
 */

@Component
public class AsyncTest {

    @Async("executor")
    public Future<String> exec(int num) throws InterruptedException {
        System.out.println(Thread.currentThread().getName() + "=======begin=======" + num + "==" + new Date());
        TimeUnit.SECONDS.sleep(num);
        System.out.println(Thread.currentThread().getName() + "=======end=======" + num + "==" + new Date());
        return AsyncResult.forValue(Thread.currentThread().getName());
    }

}
